from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, SubmitField, TextAreaField, SelectField
from wtforms.validators import DataRequired, Email, Length, EqualTo, URL, Optional

class LoginForm(FlaskForm):
    username = StringField('用户名', validators=[DataRequired()])
    password = PasswordField('密码', validators=[DataRequired()])
    remember = BooleanField('记住我')
    submit = SubmitField('登录')

class RegisterForm(FlaskForm):
    username = StringField('用户名', validators=[DataRequired(), Length(min=4, max=20)])
    email = StringField('邮箱', validators=[DataRequired(), Email()])
    password = PasswordField('密码', validators=[DataRequired(), Length(min=6)])
    confirm_password = PasswordField('确认密码', validators=[DataRequired(), EqualTo('password')])
    submit = SubmitField('注册')

class TextAnalysisForm(FlaskForm):
    text = TextAreaField('文本内容', validators=[DataRequired()])
    submit = SubmitField('分析')

class CrawlForm(FlaskForm):
    url = StringField('URL', validators=[DataRequired(), URL()])
    submit = SubmitField('采集')

class KeywordMonitorForm(FlaskForm):
    keyword = StringField('关键词', validators=[DataRequired()])
    platform = SelectField('平台', choices=[
        ('all', '全部'),
        ('news', '新闻网站'),
        ('weibo', '微博'),
        ('wechat', '微信')
    ])
    submit = SubmitField('监控')

class AlertSettingForm(FlaskForm):
    keyword = StringField('关键词', validators=[DataRequired()])
    threshold = StringField('阈值', validators=[DataRequired()])
    email_notification = BooleanField('邮件通知')
    email = StringField('通知邮箱', validators=[Optional(), Email()])
    submit = SubmitField('保存') 